//Detail的vuex仓库
import { DetailList } from "@/API/index"
import { uuid } from "@/utils/uuid_token"

const actions = {
    async reqDetail({ commit }, skuId) {
        let Detail = await DetailList(skuId)
        if (Detail.code == 200) {
            commit("DetailGET", Detail.data)
        }
    }
}
const mutations = {
    DetailGET(state, Detaildt) {
        console.log(state.uuid_tiech);
        state.DetailData = Detaildt;
    }
}
const state = {
    DetailData: {},
    uuid_tiech: uuid(),

}
const getters = {
    categoryView(state) {
        return state.DetailData.categoryView || {};     //当数据没有返回的时候，这个要保证这个是一个空对象，不让会报错（没有什么很大的影响）
    },
    skuInfo(state) {
        return state.DetailData.skuInfo || {}
    },
    spuSaleAttrList(state) {
        return state.DetailData.spuSaleAttrList || {};
    }

}
export default {
    actions,
    mutations,
    state,
    getters
}
